A gas station needs to keep
track of the current number of gallons on hand at each pump. The station has at
least one pump. Pumps are numbered 1-n with n being the total number of pumps
at the station. The handling of this data will be done by the Station
class, as described below.
private
int numPumps; // number of pumps at the station
private
double[] gallons; // number of gallons left in each pump
public
Station(int numP, double numG)
//
Creates an array of size numP and sets all pumps to numG gallons.
public
int getNumPumps()
//
Returns the number of pumps in the station.
public
double getGallonsLeft(int n)
//
Returns the number of gallons left at pump n.
public
double getTotalGallonsLeft()
//
Returns the total number of gallons left for the entire station.
public
void pumpGas(int n, double gal)
//
Deducts gal gallons from pump number n. If there are not enough
//
gallons left, the number of gallons at that pump becomes 0.0
public
void printReport()
//
Prints a report listing the number of gallons remaining at each
// pump
as well as the total number of gallons left in the station.
// See
the example report below.
Pump 1: 134.4
Pump 2: 158.6
Pump 3: 164.3
Total:
457.3
Use the file StationTest.java
to test out your class. The results of the printReport() at the end of the program should match the above
example. The file will be put in the Period 4 folder.